package com.dc.free.module.bgxm.controller;

import java.util.List;

import com.dc.free.module.bgxm.db.model.VWxBgxm;
import com.dc.free.module.bgxm.service.VWxBgxmService;
import com.dc.free.common.base.BaseController;

/**
 * @author quan
 */
public class VWxBgxmController extends BaseController {
											
	public void insert() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		boolean flag = VWxBgxmService.insert(vWxBgxm);
		if(flag) renderOk(new VWxBgxm().setGmsfhm(vWxBgxm.getGmsfhm()));
		else renderError();
	}
	
	public void update() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		boolean flag = VWxBgxmService.update(vWxBgxm) > 0;
		if(flag) renderOk();
		else renderError();
	}
	
	public void save() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		boolean flag = VWxBgxmService.save(vWxBgxm);
		if(flag) renderOk(new VWxBgxm().setGmsfhm(vWxBgxm.getGmsfhm()));
		else renderError();
	}
	
	public void delete() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		boolean flag = VWxBgxmService.delete(vWxBgxm) > 0;
		if(flag) renderOk();
		else renderError();
	}
	
	public void get() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		vWxBgxm = VWxBgxmService.get(vWxBgxm);
		renderOk(vWxBgxm);
	}
	
	public void list() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		List<VWxBgxm> vWxBgxms = VWxBgxmService.list(vWxBgxm);
		renderOk(vWxBgxms);
	}
	
	public void paginate() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		int pageSize = getParaToInt("pageSize", 10);
		int pageNumber = getParaToInt("pageNumber", 1);
		VWxBgxmService.paginate(vWxBgxm, pageSize, pageNumber);
	}
	
	public void repeat() {
		VWxBgxm vWxBgxm = getModel(VWxBgxm.class, "v_wx_bgxm");
		boolean repeat  = VWxBgxmService.repeat(vWxBgxm);
		renderOk(repeat);
	}
	
}